package com.laikan.reader.core.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.laikan.reader.R;
import com.laikan.reader.core.LaikanBaseAdapter;
import com.laikan.reader.core.bean.Search;

import java.util.List;

public class SearchContentAdapter extends LaikanBaseAdapter<Search> {

    ViewHolder holder = null;

    public SearchContentAdapter(Context context, List<Search> moreList) {
        super(context, moreList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {

        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(mContext, R.layout.lk_cate_item, null);
            convertView.setTag(holder);

            holder.book_name = (TextView)convertView.findViewById(R.id.book_name);

            holder.book_tag = (TextView)convertView.findViewById(R.id.book_tag);
            holder.book_des = (TextView)convertView.findViewById(R.id.book_des);

            holder.book_pic = (SimpleDraweeView)convertView.findViewById(R.id.book_pic);
        }else {
            holder = (ViewHolder)convertView.getTag();
        }

        holder.book_name.setText(datas.get(position).getName());
        holder.book_tag.setText(datas.get(position).getAuthorName());
        holder.book_des.setText(datas.get(position).getIntroduce());
        holder.book_pic.setImageURI(Uri.parse(datas.get(position).getIcon()));
        return convertView;
    }

    private class ViewHolder {

        public SimpleDraweeView book_pic;
        public TextView book_name, book_tag, book_des;
    }

}
